<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

/**
 * 玩家积分变化事件
 * Class PlayerMoneyChangeEvent
 * @package App\Events
 */
class PlayerMoneyChangeEvent
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $order_no;
    public $user_id;
    public $server_id;
    public $player_id;
    public $goods_id;
    public $type;
    public $trade_type;
    public $amount;
    public $cash_fee;
    public $after_money;
    public $info;

    /**
     * @param $user_id int 客户id
     * @param $server_id int 服务器id
     * @param $player_id int 玩家id
     * @param $type int 类型：1升级角色 2购买道具 3积分充值
     * @param $trade_type int 支付类型：1收入 2支出
     * @param $amount float 金额
     * @param $cash_fee float 手续费
     * @param $after_money float 交易后余额
     * @param $info string 备注
     * @param $goods_id int 商品id
     */
    public function __construct($user_id,$server_id,$player_id,$type,$trade_type,$amount,$cash_fee,$after_money,$info,$goods_id=null,$order_no='')
    {
        $this->order_no = $order_no;
        $this->user_id = $user_id;
        $this->server_id = $server_id;
        $this->player_id = $player_id;
        $this->goods_id = $goods_id;
        $this->type = $type;
        $this->trade_type = $trade_type;
        $this->amount = $amount;
        $this->cash_fee = $cash_fee;
        $this->after_money = $after_money;
        $this->info = $info;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new PrivateChannel('channel-name');
    }
}
